//
//  InsData.m
//  grainHouse
//
//  Created by zzxcc on 14-10-17.
//  Copyright (c) 2014年 zzxcc. All rights reserved.
//

#import "InsData.h"
#import "Connect.h"
#import "InsModel.h"
@implementation InsData



- (void)getdata:(MyBlock)myblock
{
//    InsModel *moder = [[InsModel alloc] init];
//    moder.user = [[NSMutableDictionary alloc] init];
    self.arrayData = [NSMutableArray array];
    Connect *connect = [[Connect alloc] init];
    
    //http://api.guju.com.cn/v2/ideabook?start=0&count=10&user=(null)&tag=全部

    NSString *string = [NSString stringWithFormat:@"http://api.guju.com.cn/v2/ideabook?start=0&count=10&user=(null)&tag=全部"];
    //网址里不能出现汉字和空格
    NSString  *unicod = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    [connect connectWithUrl:unicod pramter:nil passValue:^(id result) {
        
        NSDictionary *dicc = [[NSDictionary alloc] init];
        NSMutableArray *array = [[NSMutableArray alloc]init];
        NSMutableArray *array1 = [[NSMutableArray alloc]init];


        for (NSDictionary *dic in [result objectForKey:@"ideabooks"]) {

            InsModel *data = [[InsModel alloc]init];

            [data setValuesForKeysWithDictionary:dic];
            dicc = [dic objectForKey:@"user"];
            
            [array addObject:data];
            [array1 addObject:dicc];
        }
        for (NSDictionary *dic in [result objectForKey:@"ideabooks"] )
        {
                [_arrayData addObject:[dic objectForKey:@"photos"]];

        }

        NSLog(@"%ld",(unsigned long)[_arrayData[9] count]);
        myblock(array, array1, _arrayData);
        
    }];
    

}

@end
